<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'delete.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
   <% 	Connection con;
    	Statement sql; 
    	ResultSet rs;
   		String id="";
  
    if(request.getParameter("id")!=null)
       id=request.getParameter("id");
       
    try{  Class.forName("com.mysql.jdbc.Driver");
    	}
    catch(Exception e){
       out.println("忘记把MySQL数据库的JDBC-数据库驱动程序复制到JDK的扩展目录中");
    	}
    try { String uri= "jdbc:mysql://localhost:3306/peopletext";
          String user="root";
          String password="kamui5201";
          con=DriverManager.getConnection(uri,user,password);
          sql=con.createStatement();
          
          sql.executeUpdate("delete from pinfo where id="+id+"");
          
          con.close();
          out.println("<script language=javascript>alert('删除成功！');window.location.href='index.jsp';</script>");
         }
    catch(SQLException e){ 
         out.print(e);
    } %>
  </body>
</html>
